<?php
/*
* File：编辑用户
* Author：易如意
* QQ：51154393
* Url：www.eruyi.cn
*/

require_once 'globals.php';
include_once 'header.php';
$uid = isset($_GET['uid']) ? intval($_GET['uid']) : '';
$sql="select * from eruyi_user where uid=$uid";
$query=$db->query($sql);
$row=$db->fetch_array($query);

$money = isset($_POST['money']) ? intval($_POST['money']) : 0;
$regip = isset($_POST['regip']) ? addslashes($_POST['regip']) : '';
$markcode = isset($_POST['markcode']) ? addslashes($_POST['markcode']) : '';
$superpass = isset($_POST['superpass']) ? addslashes($_POST['superpass']) : '';

$lock = isset($_POST['lock']) ? 'y' : 'n';
$submit = isset($_POST['submit']) ? addslashes($_POST['submit']) : '';
if($submit){
	$sql="UPDATE `eruyi_user` SET `money`='$money',`regip`='$regip',`superpass`='$superpass',`markcode`='$markcode',`lock`='$lock' WHERE uid=$uid";
	$query=$db->query($sql);
	if($query){
		echo "<script>alert('编辑成功');location.href='adm_user.php';</script>";
	}
}
?>
<form action="" method="post" id="addimg" name="addimg">
<div id="post">
<div>
    <label for="user" id="user_label">用户账号：</label>
    <input type="text" maxlength="200" name="user" value="<?php echo $row['user'];?>" disabled id="user"/>
	<?php if($row['vip']>time() || $row['vip']=='999999999'): ?> <font color=red>VIP</font><?php endif; ?>
</div>
<?php if($row['vip']>time() || $row['vip']=='999999999'): ?>
<div>
    <label for="vip" id="vip_label">会员到期：</label>
	<?php $vip = $row['vip']=='999999999' ? '永久会员' : gmdate("Y-m-d H:i:s",$row['vip']+8*3600); ?>
    <input type="text" maxlength="200" name="vip" value="<?php echo $vip; ?>" disabled id="vip"/>
</div>
<?php endif; ?>
<div>
    <label for="superpass" id="superpass_label">超级密码：</label>
    <input type="text" maxlength="200" name="superpass" value="<?php echo $row['superpass'];?>" id="superpass"/>
</div>
<div>
    <label for="money" id="money_label">账户余额：</label>
    <input type="text" maxlength="200" name="money" value="<?php echo $row['money'];?>" id="money"/>
</div>
<div>
    <label for="regdate" id="regdate_label">注册时间：</label>
    <input type="text" maxlength="200" name="regdate" value="<?php echo gmdate("Y-m-d H:i:s",$row['regdate']+8*3600); ?>" disabled id="regdate"/>
</div>
<div>
    <label for="regip" id="regip_label">注册 I P：</label>
    <input type="text" maxlength="200" name="regip" value="<?php echo $row['regip'];?>" id="regip"/>
</div>
<div>
    <label for="markcode" id="markcode_label">注册机器：</label>
    <input type="text" maxlength="200" name="markcode" value="<?php echo $row['markcode'];?>" id="markcode"/>
</div>
<div>
    <label for="lock" id="lock_label">禁用账户：</label>
	<input type="checkbox" name="lock" value="lock" id="lock"<?php if($row['lock']=='y'):?> checked="checked"<?php endif; ?> /> 勾选禁用该账户
</div>
<div id="post_button">
    <input type="submit" name="submit" value="编辑保存" class="button" />
</div>
</div>
</form>
<script> 
var div = document.getElementById('adm_user'); 
div.setAttribute("class", "show"); 
</script> 
<?php 
include_once 'footer.php';
?>